package com.yzh.oop1;

/**
 * @author 于振晗
 * @title: Animal
 * @description: TODO 动物类
 * @date 2020年08月25日
 * @path com.yzh.animal
 */
public class Animal {
    private String color;//颜色
    private int age;//年龄

    public Animal(String color, int age) {
        this.color = color;
        this.age = age;
    }

    public Animal() {
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }


    public void eat(){
        System.out.println("·····eat·····");
    }

    public void rest(){
        System.out.println("·····rest·····");
    }

    @Override
    public String toString() {
        return "Animal{" +
                "color='" + color + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if(o == null){
            return false;
        }

        if(this == o){
            return true;
        }

        Animal animal = (Animal)o;
        if(this.color.equals(animal.getColor()) && this.getAge() == animal.getAge()){
            return true;
        }else{
            return false;
        }
    }

}
